<?php
class admin_theme
{
	var $module_frontpage = 0;
	var $footer_js = "";
	var $footer_jssrc = "";
	
	var $headjs = array();
	var $headcss = array();
	
	var $wrapper = "";
	
	var $mainmenu = array(); // a mainmenu elemei
	
	function admin_theme(){ 
		// alap css fileok beolvasása
		$this->add_css("theme/default.css");
		
		//jquery beolvasása, azzal rosszat nemcsinálunk az kb minden oldalon kell
		$this->add_js("../class/js/jquery.js","jquery");
		
		// néhány alap nyelvi file beolvasása
		include 'language/'.ADMIN_LNG.'/lng_menu.php';
	}
	
	function show_header()
	{
		global $user;
		
		print "<!DOCTYPE html>
		<html>
			<head>
			
				<title>Admin</title>
				
				<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
				
				<link type='image/x-icon' href='favicon.ico' rel='shortcut icon' />
				
				<link href='theme/".ADMIN_THEME."/css/style.css' rel='stylesheet' type='text/css' />
		";
		
		// css fileok beolvasása
		foreach ($this->headcss as $css) {
			print "<link href='".$css['src']."' rel='".$css['rel']."' type='text/css' />";
		}
		
		// js fileok beolvasása ha vannak egyáltalán
		if ( is_array($this->headjs) ){
			
			print "	<script src='../class/js/head.js' ></script>
					<script>
						head.js('".implode("', '", $this->headjs)."');
					</script>";
		}
					
		print "
			</head>
			<body>
		";
		
		// beolvassuk a theme-hez tartozó fejléc filet
		include 'theme/'.ADMIN_THEME.'/template_header.php';
		
		
		print $this->render_template($HEADER_TEMPLATE, array("{MAINMENU}"), $this->render_mainmenu());
		
		//print $HEADER_TEMPLATE;
		
		/*
		
		
		old header css:
		
						<link href='theme/admin_style.css' rel='stylesheet' type='text/css' />
				<link href='theme/menu_black.css' rel='stylesheet' type='text/css' />
				<link href='theme/smartpaginator.css' rel='stylesheet' type='text/css' />
				<link href='theme/jquery.lightbox.css' rel='stylesheet' type='text/css' />
				<link href='theme/picker.css' rel='stylesheet' type='text/css' />
		
		old header js:
		
		<script src='class/js/jquery.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/js/jquery-ui.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/js/jquery.metadata.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/js/jquery.hoverIntent.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/js/mbMenu.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/js/menu.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/tinymce/jscripts/tiny_mce/jquery.tinymce.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/js/smartpaginator.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/js/jquery.lightbox.js' language='JavaScript' type='text/javascript'></script>
				<script src='class/js/colorpicker.js' language='JavaScript' type='text/javascript'></script>
				<script src='https://www.google.com/jsapi' language='JavaScript' type='text/javascript'></script>
				<script language='JavaScript' type='text/javascript'>
					$().ready(function() {
						$('a.lightbox').lightBox();
						$('.datepicker').datepicker();
						$('.datepicker').datepicker('option', 'dateFormat','yy-mm-dd');
						
						$('.color_picker').ColorPicker({
							onSubmit: function(hsb, hex, rgb, el) {
								$(el).val(hex);
								$(el).ColorPickerHide();
							},
							onBeforeShow: function () {
								$(this).ColorPickerSetColor(this.value);
							}
						})
						.bind('keyup', function(){
							$(this).ColorPickerSetColor(this.value);
						});
	
						$('textarea.tinymce').tinymce({
							// Location of TinyMCE script
							script_url : 'class/tinymce/jscripts/tiny_mce/tiny_mce.js',
				
							// General options
							theme : \"advanced\",
							plugins : \"autolink,lists,table,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,advlist\",
				
							// Theme options
							theme_advanced_buttons1 : \"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontsizeselect\",
							theme_advanced_buttons2 : \"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code\",
							theme_advanced_buttons3 : \"tablecontrols,|,removeformat,visualaid,|,sub,sup,|,charmap,media,|,fullscreen\",
							theme_advanced_toolbar_location : \"top\",
							theme_advanced_toolbar_align : \"left\",
							theme_advanced_statusbar_location : \"bottom\",
							theme_advanced_resizing : true,
				
							// Drop lists for link/image/media/template dialogs
							template_external_list_url : \"lists/template_list.js\",
							external_link_list_url : \"lists/link_list.js\",
							external_image_list_url : \"lists/image_list.js\",
							media_external_list_url : \"lists/media_list.js\",
				
							// Replace values for the template plugin
							template_replace_values : {
								username : \"Some User\",
								staffid : \"991234\"
							}
						});
					});
					
					function changeimage(sender, target, url)
						{
							
							console.log('valami');
							var default_url = '".IMAGE_UPLOAD."';
							if (url == undefined)
							{
								url = default_url;
							}
						
							$('#'+target).attr('src',url+$(\"#\"+sender).val());
							$('#'+target+'_link').attr('href',url+$(\"#\"+sender).val());
							
							
							if ($(\"#\"+sender).val()=='none')
							{
								$('#'+target+'_link').hide();
							}
							else
							{
								$('#'+target+'_link').show();
							}
						}
						
						function delete_action(){
							
						}
				</script>
		
		 */
	}
	
	/**
	*
	* Enter description here ...
	*/
	function show_footer()
	{
		global $sql;
	
		$sql->mysql_close();
	
		// a template-hez tartozó lábléc megjelenítése
		include 'theme/'.ADMIN_THEME.'/template_footer.php';
		
		print "
					<div id='help_show_box' class='ui-dialog ui-widget ui-widget-content ui-corner-all'>
						<div id='help_show_box_title' class='ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix'>
						</div>
						<div id='help_show_box_text' class='ui-dialog-content ui-widget-content'>
						</div>
					</div>
				</body>
			</html>
			";
	}
	
	/**
	 * 
	 */
	function show_body(){
		
		print $this->wrapper;
	}
	
	/**
	 * 
	 * A teljes admin felület megjelenítése
	 */
	function show_site(){
		
		$this->show_header();
		
		$this->show_body();
		
		$this->show_footer();
	}
	
	/**
	 * 
	 * Head JavaScript hozzáadása
	 */
	function add_js($src,$name=""){
		
		if ($name==""){
			
			$this->headjs[] = $src;
		}else{
			
			$this->headjs[$name] = $src;
		}
		
	}
	
	function add_css($src,$rel="stylesheet"){
		
		$this->headcss[] = array(
			"src" => $src,
			"rel" => $rel
		);
	}
	
	/**
	 * 
	 * Enter description here ...
	 * 
	 * @deprecated
	 */
	function show_menu(){
		
		global $modules, $user;
		
		print "
			<div class=\"myMenu\">
				<table class=\"rootVoices left\" cellspacing='0' cellpadding='0' border='0'><tr>
	                <td class=\"rootVoice {menu: 'empty'}\" onclick=\"window.location = 'index.php';\"><img src='theme/PNG/home_14.png' /> Főoldal</td>
	                <td class=\"rootVoice {menu: 'modules' }\" ><img src='theme/PNG/gear_14.png' /> Modulok</td>
	              </tr></table>

				<table class=\"rootVoices right\" cellspacing='0' cellpadding='0' border='0'><tr>
	            	<td class=\"rootVoice {menu: 'empty'}\" onclick=\"window.location = 'logout.php';\"><img src='theme/PNG/logout_14.png' /> Kijelentkezés</td>
	              	<td class=\"rootVoice {menu: 'empty'}\" onclick=\"window.location = '../index.php';\"><img src='theme/PNG/backtomain_14.png' /> Kilépés</td>
	             </tr></table>
			
			<div class='clear'></div>
			</div>
			
		";
		
		
		/*
		 *  
		 */
		print "<div id='modules' class='mbmenu'>";
		foreach ($modules as $module_link => $module_name){
			
			if ($user->get_user_perm_check($module_link)){
				
				print "<a href='index.php?".$module_link."' class=\"{img: '".$module_link."_24.png'}\">".$module_name."</a>";
			}
		}
		print "</div>";
	}
	
	/**
	 * 
	 * Enter description here ...
	 * 
	 * @return String A menü szövege
	 */
	function render_mainmenu($activemenu=""){
		
		if ( ADMINLOGIN === TRUE ){

			$menutext = "";
		}else{
			
			$menutext = "";
			
			$menutext .= "<ul class='menu mainmenu'>";
				
			foreach ($this->mainmenu as $menu) {
					
				$menutext .= "
				<li class='".$menu['class']." ".($activemenu == $menu['link']?"selected":"")."'>
				<a href='".$menu['link']."'>
				".$menu['text']."
				</a>
				</li>";
			}
				
			$menutext .= "</ul>";
		}
		
		/*
		$menutext = "
			
				<li><a href='index.php'>".HOTNADMIN_LNG_DASHBOARD."</a></li>
				<li><a href='index.php.analytics.today'>".HOTNADMIN_LNG_DASHBOARD_ANALYTICS."</a></li>
			</ul>
		";
		*/
		
		return $menutext;
	}
	
	/**
	 * 
	 * Új menü elem hozzáadása
	 * @param Array $menu a menü elem 
	 */
	function add_mainmenu($menu){
		$this->mainmenu[] = $menu;
	}
	
	
	function show_page($menu="")
	{
		global $page_title, $page_text, $query_string;
		
		print "
		<table class='admin_page'>
			<tr>
				<td >
		";
		
		if (is_array($_SESSION['message']['error']))
		{
			print "
			<div class='ui-widget admin_message'>
				<div style='padding: 0 .7em;' class='ui-state-error ui-corner-all'> 
					<p>
						<span style='float: left; margin-right: .3em;' class='ui-icon ui-icon-alert'></span>
						".implode("<br />", $_SESSION['message']['error'])."
					</p>
				</div>
			</div>
			";
			
			$_SESSION['message']['error'] = "";
		}
		
		if (is_array($_SESSION['message']['highlight']))
		{
			print "
			<div class='ui-widget admin_message'>
				<div style='padding: 0 .7em;' class='ui-state-highlight ui-corner-all'> 
					<p>
						<span style='float: left; margin-right: .3em;' class='ui-icon ui-icon-info'></span>
						".implode("<br />", $_SESSION['message']['highlight'])."
					</p>
				</div>
			</div>
			";
			
			$_SESSION['message']['highlight'] = "";
		}
		
		
		print "			<div class='admin_box ui-dialog ui-widget ui-widget-content ui-corner-all'>
						<div class='admin_title ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix'>
							".$page_title."
						</div>
						<div class='admin_text ui-dialog-content ui-widget-content'>
							".$page_text."
						</div>
					</div>
				</td>
		";
		
		if ($menu<>"")
		{
			print "
				<td class='admin_menu'>
					<div class='ui-dialog ui-widget ui-widget-content ui-corner-all'>
						<div class='menu_title ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix'>
							Menü
						</div>
						<div class='menu_text ui-dialog-content ui-widget-content'>
			";
			
			if (is_array($menu))
			{
				foreach ($menu as $link => $value) {
					print "<a class='".($link==$query_string[1]?"active_link ":"")."ui-button ui-widget ui-state-default ui-corner-right ui-button-text-only' href='index.php?".$value['link']."'>".$value['title']."</a>";
				}
			}
			else
			{
				print $menu;
			}
			
			print "			
						</div>
					</div>
				</td>
			";
		}
		
		print "
			</tr>
		</table>
		";
	}
	
	function show_frontpage_module($module_name, $module_title)
	{
		$this->module_frontpage++;
		
		return "
			<div class='frontpage_module'>
				<a href='index.php?".$module_name."'>
					<div class='module_img'>
						<img src='theme/PNG/".$module_name."_64.png' />
					</div>
					<div class='modul_title'>
						<span class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'>".$module_title."</span>
					</div>
				</a>
			</div>
		";
	}
	
	/**
	 * 
	 * Form elemeinek megjelenítése
	 * @param array $data - A form elemeinek tömbös elrendezése
	 * @return string - a form HTML kódja
	 */
	function show_form($data)
	{
		
		global $form_value;
		
		$form_text = "
			<div class='admin_form ui-widget'>
				<form action='".($data['action']<>""?$data['action']:"form_action.php")."' method='post' ".($data['type']=="upload"?"enctype='multipart/form-data'":"").">
				<input type='hidden' name='action' value='".$form_value['action']."' />
				<input type='hidden' name='module' value='".$form_value['module']."' />
				<input type='hidden' name='id' value='".$form_value['id']."' />
				<input type='hidden' name='multitable' value='".DB_TABLE."' />
		";
		
		if ($data['multitable'])
		{
			$data = $data[DB_TABLE];
		}
		
		foreach ($data['data'] as $form) 
		{
			if ($form['type']!="hidden" && $form['type']!="id" && $form['type']!="module")
			{
				$form_text .= "<div class='fieldset'>";
				$form_text .= "<div class='legend'><span class='left title'>".$form['title']."</span>";
				if ($form['help-text']<>"")
				{
					$form_text .= "<span info-text='".$form['help-text']."' info-title='".$form['title']."' class='ui-icon ui-icon-info help-box left'></span>";
				}
				$form_text .= "</div><div class='clear'></div>";
			}
			
			if ($form['type']=="module")
			{
				$form_text .= "<input type='hidden' name='module' value='".$form['value']."' />";
			}
			
			if ($form['type']=="hidden")
			{
				$form_text .= "<input type='hidden' name='".$form['name']."' value='".($form['value']<>""?$form['value']:$form_value[$form['name']])."' />";
			}
			
			if ($form['type']=="text")
			{
				$form_text .= "<input class='text ui-widget-content ui-state-default ui-corner-all' type='text' name='".$form['name']."' maxlength='".$form['max']."' value='".$form_value[$form['name']]."' />";
			}
			
			if ($form['type']=="password")
			{
				$form_text .= "<input class='text ui-widget-content ui-state-default ui-corner-all' type='password' name='".$form['name']."' maxlength='".$form['max']."' value='".$form_value[$form['name']]."' />";
			}
			
			if ($form['type']=="number")
			{
				$form_text .= "<input class='text ui-widget-content ui-state-default ui-corner-all' type='number' name='".$form['name']."' value='".$form_value[$form['name']]."' />";
			}
			
			if ($form['type']=="select")
			{
				$form_text .= "<select class='select ui-widget-content ui-state-default ui-corner-all' name='".$form['name']."'>
					<option value='0'>None</option>
				";
				foreach ($form['ittems'] as $value_id => $value_text)
				{
					$form_text .= "<option ".($form_value[$form['name']]==$value_id?"selected":"")." value='".$value_id."'>".$value_text."</option>";
				}
				$form_text .= "</select>";
			}
			
			if ($form['type']=="textarea")
			{
				$form_text .= "
					<textarea class='textarea ui-widget-content ui-state-default ui-corner-all' name='".$form['name']."'>".$form_value[$form['name']]."</textarea>
				";
			}
			
			if ($form['type']=="tinymce")
			{
				$form_text .= "
					<textarea class='textarea tinymce ui-widget-content ui-state-default ui-corner-all' name='".$form['name']."'>".$form_value[$form['name']]."</textarea>
				";
			}
			
			if ($form['type']=="checkbox")
			{
				$form_text .= "
					<input class='ui-widget-content ui-state-default ui-corner-all' type='checkbox' name='".$form['name']."' ".($form_value[$form['name']]==1?"checked":"")." />
				";
			}
			
			if ($form['type'] == "checkboxlist")
			{
				foreach ($form['ittems'] as $ittemname => $ittemvalue)
				$form_text .= "
					<input class='text ui-widget-content ui-state-default ui-corner-all' type='checkbox' value='".$ittemname."' name='".$form['name']."[]' ".($form_value[$ittemname]==1?"checked":"")." />".$ittemvalue."<br />";
			}
			
			if ($form['type']=="date")
			{
				$form_text .= "<input id='datepicker' class='datepicker text ui-widget-content ui-state-default ui-corner-all' type='text' name='".$form['name']."' value='".$form['value']."' />";
				$this->footer_jssrc[] = "$('#datepicker').datepicker('setDate', new Date ( '".($form_value[$form['name']]<>""?$form['value']:date("Y-m-d"))."' ));";
			}
			
			if ($form['type']=="datetime")
			{
				$form_text .= "<input id='datepicker' class='datepicker text ui-widget-content ui-state-default ui-corner-all' type='text' name='".$form['name']."_date' value='".$form['value']."' />";
				$this->footer_jssrc[] = "$('#datepicker').datepicker('setDate', new Date ( '".($form_value[$form['name']]<>""?$form['value']:date("Y-m-d"))."' ));";
			}
			
			if ($form['type']=="colorpicker")
			{
				//$form_text .= "<input class='colorpicker text ui-widget-content ui-state-default ui-corner-all' type='text' name='".$form['name']."' value='".$form['value']."' />";
				$form_text .= "<input type='text' class='color_picker text ui-widget-content ui-state-default ui-corner-all' maxlength='6' size='6' id='".$form['name']."' name='".$form['name']."' value='".$form_value[$form['name']]."'/>";
				$this->footer_jssrc[] = "$('#".$form['name']."').ColorPickerSetColor('".$form_value[$form['name']]."');\n";
			}
			
			if ($form['type']=="image")
			{

				$form_text .= "<a id='news_image_link' href='".IMAGE_UPLOAD.$form_value[$form['name']]."' class='lightbox' ".(empty($form_value[$form['name']])?"style='display:none'":"")."><img class='ui-corner-all' id='news_image' src='".IMAGE_UPLOAD.$form_value[$form['name']]."' width='100px'></a>";
				
				if ($handle = opendir(IMAGE_UPLOAD)) 
				{
					$form_text .= "<br /><select id='".$form['name']."_imagefile' name='".$form['name']."_imagefile' class='select ui-widget-content ui-state-default ui-corner-all' >
						<option value='none'>Feltöltés</option>";
				    while (false !== ($file = readdir($handle))) 
				    {
				    	if ($file<>"." && $file<>".." && !is_dir(IMAGE_UPLOAD."/".$file))
				    	{
				    		$form_text .= "<option ".($form_value[$form['name']]==$file?"selected":"")." value='".$file."'>".$file."</option>";
				    	}
				    }
				    $form_text .= "</select>";

				    closedir($handle);
				}
				
				$form_text .= "<input type='file' class='file ui-widget-content ui-state-default ui-corner-all' name='".$form['name']."_imageupload' />";
			}
			
			if ($form['type']=="file")
			{
				$form_text .= "<input type='file' class='file ui-widget-content ui-state-default ui-corner-all' name='".$form['name']."'>";
			}
			
			if ($form['type']!="hidden" && $form['type']!="id" && $form['type']!="module")
			{
				$form_text .= "</div>";
			}
		}
		
		$form_text .= "
					<div class='admin_button'>
						<input type='submit' value='Mentés' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'>
					</div>
				</form>
			</div>
		";
		
		return $form_text;
	}
	
	// Form lista rendelerő
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 */
	function show_form_text($form)
	{
		$return = "";
		$return .= $this->render_label($form);
		$return .= $this->render_input_text($form);
		
		return $return;
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 * @return string
	 */
	function show_form_number($form)
	{
		$return = "";
		$return .= $this->render_label($form);
		$return .= $this->render_input_number($form);
		
		return $return;
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 */
	function show_form_select($form)
	{
		$return = "";
		$return .= $this->render_label($form);
		$return .= $this->render_input_select($form);
		
		return $return;
	}
	
	// Egyszerűsített form elem megjelenítő
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 */
	function render_label($form)
	{
		return "<label class='label ".$form['title_class']."'>".$form['title']."</label>";
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 * @return unknown
	 */
	function render_hidden($form){
		return "<input type='hidden' name='".$form['name']."' value='".$form['value']."' />";
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 * @return string
	 */
	function render_input($form){
		return "<input 
		class='ui-widget-content ui-state-default ui-corner-all ".$form['class']."' 
		type='".$form['type']."' 
		id='".($form['id']<>""?$form['id']:$form['name'])."' 
		name='".$form['name']."' 
		maxlength='".$form['max']."' 
		value='".$form['value']."' 
		style='".$form['style']."' 
		".$form['other']." />";
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 */
	function render_input_text($form){
		$form['type'] = "text";
		$form['class'] .= " text";
		
		return $this->render_input($form);
	}
	
	function render_input_password($form){
		$form['type'] = "password";
		$form['class'] .= " text";
		
		return $this->render_input($form);
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 * @return string
	 */
	function render_input_number($form){
		$form['type'] = "number";
		$form['class'] .= " number text";
		$form['other'] .= " max='".$form['max']."' min='".$form['min']."'";
		
		return $this->render_input($form);
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 */
	function render_input_checkbox($form){
		$form['type'] = "checkbox";
		$form['class'] .= " checkbox";
		
		return $this->render_input($form);
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 * @return string
	 */
	function render_input_date($form){
		$form['type'] = "text";
		$form['class'] .= " datepicker text";
		$form['id'] = "datepicker-".$form['name'];
		
		$this->footer_jssrc[] = "$('#".$form['id']."').datepicker('setDate', new Date ( '".($form['value']<>""?$form['value']:date("Y-m-d"))."' ));";
		
		return $this->render_input($form);
	}
	
	/**
	*
	* Enter description here ...
	* @param unknown_type $form
	* @return string
	*/
	function render_input_datetime($form){
		$formtext = "";
		
		$form['type'] = "text";
		$form['class'] .= " datepicker text";
		$form['id'] = "datepicker-".$form['name'];
	
		$this->footer_jssrc[] = "$('#".$form['id']."').datepicker('setDate', new Date ( '".($form['value']<>""?$form['value']:date("Y-m-d"))."' ));";
	
		$formtext .= $this->render_input($form);
		$formtext .= $this->render_input_number($form);
		$formtext .= $this->render_input_number($form);
		
		return $formtext;
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 * @return string
	 */
	function render_input_colorpicker($form){
		$form['type'] = "text";
		$form['class'] .= " colorpicker text";
		$form['id'] = "colorpicker-".$form['name'];
		
		$this->footer_jssrc[] = "$('#".$form['id']."').ColorPickerSetColor('".$form['value']."');";
		
		return $this->render_input($form);

	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 * @return string
	 */
	function render_input_select($form){
		$return = "";
		
		$return .= "<select class='select ui-widget-content ui-state-default ui-corner-all' id='".($form['id']<>""?$form['id']:$form['name'])."' name='".$form['name']."' style='".$form['style']."' ".$form['other'].">
							<option value='0'>None</option>
						";
		foreach ($form['ittems'] as $value_id => $value_text)
		{
			$return .= "<option ".($form['value']==$value_id?"selected":"")." value='".$value_id."'>".$value_text."</option>";
		}
		$return .= "</select>";
		
		return $return;
	}
	
	function render_advancedimage($form){
		$formtext = "";
		
		
		
		return $formtext;
	}
	
	/**
	*
	* Enter description here ...
	* @param unknown_type $form
	*/
	function render_checkboxlist($form){
		$formtext = "";
	
		foreach ($form['ittems'] as $ittemname => $ittemvalue){
	
			$formarray = $form;
			$formarray['value'] = $ittemname;
				
			$formtext .= $this->render_input_checkbox($formarray);
			$formtext .= "<br />";
		}
	
		return $formtext;
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 */
	function render_textarea($form){
		
		$return = "<textarea class='textarea ui-widget-content ui-state-default ui-corner-all ".$form['class']."' id='".($form['id']<>""?$form['id']:$form['name'])."' name='".$form['name']."' style='".$form['style']."' ".$form['other']." >".$form['value']."</textarea>";
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $form
	 */
	function render_textarea_tinymce($form){
		$form['class'] .= " tinymce";
		
		return $this->render_textarea($form);
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param unknown_type $template
	 * @param unknown_type $search
	 * @param unknown_type $replace
	 * @return string
	 */
	function render_template($template,$search,$replace){
		$templatetext = "";
		
		$templatetext .= str_replace($search,$replace,$template);
		
		return $templatetext;
	}
	
	/**
	 * 
	 * Enter description here ...
	 * @param String $module
	 * @param String $subpage
	 * @param String $subedit
	 * @param Integer $max
	 * @param Integer $current
	 * @param Array $data
	 * @param Array $show
	 * @param String $table
	 * @return string
	 */
	function render_db_list($module,$subpage,$subedit,$max,$current,$data,$show,$table="",$edit_url="index.php",$delete_url="form_delete.php",$otherlinks=array())
	{
		$text = "
			<table cellpadding='0' cellspacing='0' class='admin_list ui-corner-all'>
				<tr class='admin_list_header'>";
		
		foreach ($show as $showrow)
		{
			$text .= "
					<td class='admin_list_".$showrow['type']." ui-widget-header ui-corner-bottom'>
						".$showrow['title']."
					</td>
			";
		}
		
		$text .= "
					<td class='admin_list_action ui-widget-header ui-corner-bottom'>
						Műveletek
					</td>
				</tr>";
		
		foreach ($data as $datarow)
		{
			$text .= "
				<tr class='admin_list_body'>";
				foreach ($show as $showtype => $showrow)
				{
					
					if ($showrow['type']=="id") $table_id = $showtype;
					
					if ($showrow['type']=="category" && $showrow['array']<>"")
					{
						$datarow[$showtype] = $showrow['array'][$datarow[$showtype]];
					}
					
					if ($showrow['type'] == "date")
					{
						$datarow[$showtype] = date("Y-m-d",$datarow[$showtype]);
					}
					
					if ($showrow['type'] == "image")
					{
						$datarow[$showtype] = "<img src='".$datarow[$showtype]."'>";
					}
					
					$text .= "<td class='admin_list_".$showrow['type']."'>".$datarow[$showtype]."</td>";
				}
			$text .= "
					<td class='admin_list_action'>
						<a href='".$edit_url."?".$module.".".$subedit.".".$datarow[$table_id]."' class='ui-icon ui-icon-pencil' title='Szerkesztés'></a>
						<a href='".$delete_url."?action=delete&module=".$module."&subpage=".$subpage."&table=".$table."&id=".$datarow[$table_id]."' class='ui-icon ui-icon-trash' title='Törlés' onclick='return confirm(\"Biztos, hogy törölni akarja?\");'></a>";
			
			foreach ($otherlinks as $links) {
				$link = str_replace(array("{ID}"), array($datarow[$table_id]), $links['url']);
				
				$class = $links['class'];
				$title = $links['title'];
				$onclick = $links['onclick'];
				
				$text .= "<a href='".$link."' class='ui-icon ".$class."' title='".$title."' onclick='".$onclick."'></a>";
			}
			
			$text .= "					
					</td>
				</tr>";
		}
		
		
		$text .= "
			</table>
		<div id='smart-paginator'></div>";
		
		$this->footer_jssrc[] = "
			$('#smart-paginator').smartpaginator({ totalrecords: ".$max.", recordsperpage: 20, initval:".$current." , next: 'Következő', prev: 'Előző', first: 'Első', last: 'Utolsó', theme: 'black', onchange: onChange});
			
			function onChange(newPageValue) {
				window.location.href= 'index.php?".$module.".".$subpage.".'+newPageValue;
			}
		";
		
		return $text;
	}
}

?>